package com.diankangwo.util;


import gui.ava.html.image.generator.HtmlImageGenerator;

/** HTML 转 image
 * Created by wuye on 2017/9/26.
 */
public class HtmlToImage {

    public static void main(String[] args) {
        String address = "/Users/wuye/Downloads/text/";
        HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
//        imageGenerator
//                .loadHtml("http://118.89.20.141/index.html");
        imageGenerator.loadUrl("http://118.89.20.141/index.htm");
        String imageName = UUIDUtil.getUUID()+".png";
        imageGenerator.saveAsImage(address+imageName);
        System.out.println(address+imageName);
        imageGenerator.saveAsHtmlWithMap(imageName+".html", imageName+".png");
    }

    /**
     *
     * @param url html地址
     * @param fileAddress 本地觉得路径（/user/local/src/textimage/）
     * @return
     */
    public static String htmltoImage(String url,String fileAddress){
        String address = fileAddress;
        HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
//        imageGenerator
//                .loadHtml("<b>Hello World!</b> Please goto <a title=\"Goto Google\" href=\"http://www.google.com\">Google</a>.");
        imageGenerator.loadUrl(url);
        String imageName = UUIDUtil.getUUID()+".png";
        imageGenerator.saveAsImage(address+imageName);
//        imageGenerator.saveAsHtmlWithMap(imageName+".html", imageName+".png");
        String imgAddress = address+imageName;
        return imgAddress;
    }
}
